package com.jp.knowledge.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.jp.knowledge.R;
import com.jp.knowledge.model.TiyanUseData;
import com.jp.knowledge.util.ImageLoadUtil;

import java.util.List;

/**
 * Created by jiayen on 16/11/3.
 */

public   class TiyanUseAdaper extends JpBaseRecyViewAdapter {

    private Context mContext;
    private List<TiyanUseData> list;
    public TiyanUseAdaper( Context context,List<TiyanUseData> list){
        super(context,list);
        this.mContext=context;
        this.list=list;

    }
    public void update(List<TiyanUseData> list){
        this.list=list;
        notifyDataSetChanged();
    }

    @Override
    public int getLayoutId() {
        return R.layout.com_text_layout;
    }

    @Override
    public void bindViewHold(JPRecycleViewHolder holder, int position) {
    if(list!=null&&list.size()>0)
        renderData(holder,position,list.get(position));
    }

    protected void renderData(JPRecycleViewHolder holder, int position, TiyanUseData newDataBean) {
        ImageView img = holder.getView(R.id.icon);
        TextView name = holder.getView(R.id.name);
        ImageLoadUtil.loadrund(mContext,newDataBean.getIcon(),img,10);
        name.setText(newDataBean.getName());
    }


}